package com.example.httpclient.Adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.httpclient.R;
import com.example.httpclient.UI.myViewHolder;

import java.util.ArrayList;

public class RecycleAdapter extends RecyclerView.Adapter<com.example.httpclient.UI.myViewHolder> {
    public OnClickItemListener onClickItemListener;
    private Context context;
    private ArrayList<Bitmap> BitmapList;

    public RecycleAdapter(Context context,ArrayList<Bitmap> BitmapList){
        this.context=context;
        this.BitmapList=BitmapList;
    }
    public void setNewList(ArrayList<Bitmap> bitmapList){
        this.BitmapList=bitmapList;

    }

    public void setOnItemClickListener(OnClickItemListener onClickItemListener){
        this.onClickItemListener=onClickItemListener;
    }
    @NonNull
    @Override
    public myViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view=LayoutInflater.from(context).inflate(R.layout.layout_recycle_item,parent,false);
        return new myViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull myViewHolder holder, int position) {
        holder.setData(BitmapList.get(position));
    }

    @Override
    public int getItemCount() {
        return BitmapList.size();
    }
}
